<template>


  <div class="common-layout">
    <el-container>
      <el-aside width="300px" >
<!--        <el-input-->
<!--            v-model="contactsName"-->
<!--            class="w-50 m-2"-->
<!--            placeholder="输入姓名"-->
<!--            :prefix-icon="Search"-->

<!--        /><el-icon><Search /></el-icon>-->


        <div>
          <el-table :data="teacher" height="90" @cell-click="selTea" style="width: 100%;background-color: rgb(236,245,255)">
            <el-table-column  prop="teaName"   label="教师名" width="180" />
          </el-table>
        </div>
        <div>
          <el-table :data="studentName" @cell-click="selStu" height="250" style="width: 100%">
            <el-table-column prop="stuName"  label="好友名" width="180" />
          </el-table>
        </div>


        </el-aside>
      <el-main >
        <router-view></router-view>

      </el-main>
    </el-container>
  </div>
</template>

<script>
import {Search} from "@element-plus/icons-vue";
import {useLoginStateStore} from "../../store/storeLoginState.js";

export default {
  name: "AnsQuestion",
  setup(){
      const loginStateStore = useLoginStateStore()
      return {
        loginStateStore: loginStateStore,
        Search
      }
  },
  data(){
    return{
      contactsName:"",
      studentName:[
        {
          stuName:'',
          stuNum:'',
        }
      ],
      teacher:[
        {
          teaName:'',
          teaNum:'',
        }
      ],

    }
  },
  mounted() {
    let _this=this;

    let stuNum=window.sessionStorage.getItem("userNum")
    let url="/studyadmin/student/stulist";
    _this.$axios.post(url).then(function (serverData) {
      console.log("学生内容数据：", serverData.data.data)
      if (serverData.data.code == 0) {

        for (let i=0;i<serverData.data.data.length;i++){
          let s=serverData.data.data;
          // console.log("klklk",serverData.data.data[i].stuNum)
          if(stuNum!==serverData.data.data[i].stuNum){
            _this.studentName.push({stuName:s[i].stuName,stuNum:s[i].stuNum,name:s[i].teaName})
          }
        }
      }
    })

    _this.$axios.post("/studyadmin/teacher/teaList").then(function (serverData) {
      console.log("教师内容数据：", serverData.data.data)
      if (serverData.data.code == 0) {

        for (let i=0;i<serverData.data.data.length;i++){
          let s=serverData.data.data;
          console.log("klklk",serverData.data.data[i].teaName)
          // _this.teacher.push({teaName: })
          _this.teacher.push({teaName:s[i].teaName,teaNum:s[i].teaNum})
          // _this.teacher.push({})
        }
      }

    })

  },
  methods: {
    searchStu(){

    },
    //选择要联系的学生
    selStu(row){
      console.log("----------------",row)
      // alert("0000")
      let _this=this
      _this.$router.push({name:'TeaQuestion',query: {receiveNum:row.stuNum,name:row.stuName},replace:true})
    //
    },
    selTea(row){
      console.log(row.teaNum)
      let _this=this
      _this.$router.push({name:'TeaQuestion',query: {receiveNum:row.teaNum,name:row.teaName},replace:true})

    }


  },


}
</script>

<style scoped>

</style>
